﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities.Auditing;

namespace ARchGL.Platform.Core
{
    /// <summary>
    /// 文件库 数据实体
    /// </summary>
    [Table("JN_" + nameof(DocumentLibrarys))]
    public class DocumentLibrarys : EntitySoftDeleteBase, IHasModificationTime
    {
        /// <summary>
        /// 主键标识（项目/人员等等）
        /// </summary>
        public Guid? PrimaryId { get; set; }

        /// <summary>
        /// 《检验批》验收节点标识
        /// </summary>
        public Guid PrimaryId1 { get; set; }
        ///// <summary>
        ///// 场景标识
        ///// </summary>
        //public Guid PrimaryId2 { get; set; }
        /// <summary>
        /// 上级分类
        /// </summary>
        public Guid? ParentId { get; set; }
        /// <summary>
        /// 文件/文件夹 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 大小（存储单位为 B）
        /// </summary>
        public int Size { get; set; }
        /// <summary>
        /// 文件标识来自文件系统，如果没有则是文件夹
        /// </summary>
        public Guid? FileId { get; set; }
        /// <summary>
        /// 链接地址
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 扩展名
        /// </summary>
        public string Extension { get; set; }

        /// <summary>
        /// 文件hash
        /// </summary>
        [MaxLength(50)]
        public string Hash { get; set; }

        /// <summary>
        /// 文件Path
        /// </summary>
        [MaxLength(200)]
        public string Path { get; set; }

        /// <summary>
        /// 上传TaskId
        /// </summary>
        [MaxLength(50)]
        public Guid TaskId { get; set; }

        /// <summary>
        /// 文件上传成功后返回数据
        /// </summary>
        [MaxLength(1000)]
        public string FileResponse { get; set; }

        /// <summary>
        /// 文件状态Zhuye
        /// 0 已上传
        /// 1 正在转换
        /// 2 转换成功
        /// </summary>
        public EnumFileStatus FileState { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 是否文件夹
        /// </summary>
        /// <returns></returns>
        public bool IsFolder
        {
            get
            {
                return !FileId.HasValue || FileId == Guid.Empty;
            }
        }

        /// <summary>
        /// 类型
        /// </summary>
        public EnumDocumentPType PType { get; set; }


        /// <summary>
        /// 是否同步 false/true
        /// </summary>
        public bool State { get; set; }

        /// <summary>
        /// 是否系统级
        /// 系统设置不允许删除
        /// </summary>
        public bool IsSystem { get; set; }

        /// <summary>
        /// 透传字段
        /// </summary>
        [MaxLength(1000)]
        public string TransInfo { get; set; }

        /// <summary>
        /// 模板标识
        /// </summary>
        public Guid TemplateId { get; set; }

        /// <summary>
        /// 验收节点：创建进度参数
        /// </summary>
        public string MppRequest { get; set; }

        /// <summary>
        /// 验收节点：创建进度结果
        /// </summary>
        public string MppResponse { get; set; }

        /// <summary>
        /// 验收节点：创建进度时间
        /// </summary>
        public DateTime? MppCreateTime { get; set; }
    }

    /// <summary>
    /// 分享信息 数据实体
    /// </summary>
    [Table("JN_" + nameof(DocumentShares))]
    public class DocumentShares : EntityBase
    {
        /// <summary>
        /// 文件/文件夹 标识
        /// </summary>
        public Guid DocumentLibraryId { get; set; }
        /// <summary>
        /// 提取码
        /// </summary>
        public string Password { get; set; }
        /// <summary>
        /// 分享链接，系统生成
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 查看数
        /// </summary>
        public int ViewCount { get; set; }
        /// <summary>
        /// 保存数
        /// </summary>
        public int SaveCount { get; set; }
        /// <summary>
        /// 下载数
        /// </summary>
        public int DownloadCount { get; set; }
        /// <summary>
        /// 失效时间，为空时无限制
        /// </summary>
        public DateTime? ExpiresTime { get; set; }
    }
}
